<template>
	<view>
		<view class="user">
			<image src='../../static/my_normal.png' class="tx" v-if="!isLogin"></image>
			<image src='../../static/head_icon.png' class="tx" v-else></image>
			<view>
			<text class="name" v-if="isLogin">{{list.name}}</text>
			<button v-else type="primary" class="denglu" size="default" @click="toLogin">登录</button>
			</view>
		</view>
		<view class="container">
			<view style="width: 100%;">
				<view class="entries">
					<view class="x"></view>
					<view class="entry">
						<image src="../../static/UserInfo.png" class="xtp"></image>
						<text>个人信息</text>
						<image src="../../static/more.png" class="xtp"></image>
					</view>
					<view class="x"></view>
					<view class="entry">
						<image src="../../static/purchaseorder.png" class="xtp"></image>
						<text>订单列表</text>
						<image src="../../static/more.png" class="xtp"></image>
					</view>
					<view class="x"></view>
					<view class="entry">
						<image src="../../static/modify-password.png" class="xtp"></image>
						<text>修改密码</text>
						<image src="../../static/more.png" class="xtp"></image>
					</view>
					<view class="x"></view>
					<view class="entry">
						<image src="../../static/pl.png" class="xtp"></image>
						<text>意见反馈</text>
						<image src="../../static/more.png" class="xtp"></image>
					</view>
					<view class="x"></view>

				</view>
				<button class="tuchu" type="primary" size="default" :disabled="!isLogin" @click="logout">退出</button>
				
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: {
					"name": 'tom',

				},
				isLogin:false
			}
		},
		onShow() {
			this.getUserInfo()
		},
		onLoad() {

		},
		methods: {
			logout() {
				uni.setStorageSync('list', null)
				this.isLogin = false
				this.getUserInfo()
			},
			getUserInfo() {
				let list = uni.getStorageSync('list', null)
				if (list) {
					this.isLogin = true
					this.list = list
				} else {
					this.isLogin = false
					this.list.icon = '/static/head_icon.png'
				}
			},
			toLogin() {
				uni.navigateTo({
					url: '/pages/my/login'
				})
			}
		}
	}
</script>

<style>
	.x{
		width: 90%;
		height: 1rpx; 
		background-color:#CCC;
		margin-bottom: 5px;
	}
	.user {
		/* background-color: azure; */
		display: flex;
		align-items: center;
		width: 100%;
		height: 180px;
		/* margin-top: 15px; */
		/* display: inline; */
	}

	.tx {
		margin-left: 25px;
		width: 80px;
		height: 80px;
		border-radius: 25%;
	}

	.name {
		color: #9da7ad;
		margin-left: 25px;
		display: flex;
		align-items: center;
		width: 100%;
		height: 180px;
	}

	.denglu{
		width: 85px;
		height: 45px;
		margin: 15px;
	}

	.container {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 100%;
		/* background-color: #007AFF; */
		/* margin-top: 60px; */
	}

	.entries {
		margin-top: 12px;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.entry {
		display: flex;
		flex-direction: row;
		height: 50px;
		width: 90%;
		justify-content: space-between;
	}

	.entry>text {
		display: block;
		height: 40px;
		width: 200px;
		margin-top: 13px;
	}

	.tuchu{
		margin-top: 20px;
		width: 90vw;
	}
	.xtp{
		width: 40px; 
		height: 40px;
	}
</style>